package com.itcat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcat.mysql.pojo.CmsPrefrenceAreaProductRelation;
import com.itcat.mysql.pojo.PmsProductAttributeValue;
import com.itcat.mysql.pojo.PmsProductFullReduction;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author 小心触碰的电脑
* @description 针对表【pms_product_full_reduction(产品满减表(只针对同商品))】的数据库操作Mapper
* @createDate 2022-04-03 16:20:50
* @Entity com.itcat.mysql.pojo.PmsProductFullReduction
*/
@Mapper
public interface PmsProductFullReductionMapper extends BaseMapper<PmsProductFullReduction> {

    @Insert({"<script> " +
            "insert into pms_product_full_reduction  ( product_id, full_price, reduce_price)values" +
            " <foreach collection='list' item='item' index='index' separator=',' > " +
            "( #{item.productId}, #{item.fullPrice}, #{item.reducePrice})" +
            "</foreach>" +
            "</script>"})
    int batchInsert(@Param("list") List<PmsProductFullReduction> list);

    @Update({"<script> " +
            "<foreach collection='list' item='item' index='index' separator=';'> " +
            "UPDATE pms_product_full_reduction " +
            "SET product_id = #{item.productId}, full_price= #{item.fullPrice}, reduce_price=#{item.reducePrice}  " +
            "WHERE id = #{item.id} </foreach> </script>"})
    int batchUpdate(@Param("list") List<PmsProductFullReduction> list);

}
